{extend name="base"/}
{block name="content"}
<link rel="stylesheet" type="text/css" href="__THEMES__/layui/css/layui.css"/>
<script type="text/javascript" src="__THEMES__/layui/layui.all.js"></script> 
<!-- Wrapper -->
<div class="wrapper">
<!-- Topic Header -->
  <div class="topic">
    <div class="container">
      <div class="row">            
        <ol class="breadcrumb hidden-xs">
          <li><a href="{:url('tcms/index/index')}">首页</a></li>
          <li><a href="{:url('tcms/Posts/index')}">文章</a></li>
          <li class="active">详情</li>
        </ol>                      
      </div>
    </div>
  </div> 
  {assign name="id" value=":input('id')"}
  {php}Core::loadAction("Posts/updateView",["id"=>$id]);{/php}
  <div class="container">
    <div class="row">
      <div class="col-sm-9">
        <!-- Blog Post #1 -->
        <div class="blog">
          {empty name="list.thumb"}
          <img src="__THEMES__/img/default_post.jpg" alt="{$list.title}">
          {else/}
          <img src="{$list.thumb}" alt="{$list.title}">
          {/empty}
          <div class="blog-desc">
            <h3>
              <a href="">{$list.title}</a>
            </h3>
            <hr>
            <p class="text-muted">文章来源：{$list.source}&nbsp;&nbsp;&nbsp;&nbsp;发布时间：{$list.updatetime|date='Y-m-d H:i:s',###}&nbsp;&nbsp;&nbsp;&nbsp;浏览：{$list.view}</p>
            <div class="posts-content">
              {$list.content}               
            </div>
          </div>
        </div>

        <!-- Pagination -->
        <ul class="pager pull-right" style="font-size: 16px;">
          <li style="margin-right: 10px;">上一篇：{:Core::loadAction("Posts/preNextPost",["parentid"=>1,"id"=>$id,"option"=>"pre"])}</li>
          <li>下一篇：{:Core::loadAction("Posts/preNextPost",["parentid"=>1,"id"=>$id,"option"=>"next"])}</li>
        </ul>
        <div class="clearfix"></div>
        
        <div class="comments" id="reply">
        <!-- New comment form -->
          <div class="cmt">
            {empty name="Request.session.tpf_login_sign.headimg"}
            <img src="__THEMES__/img/avatar-default.jpg" alt="用户头像">
            {else/}
            <img src="{$Request.session.tpf_login_sign.headimg}" alt="{$Request.session.tpf_login_sign.nickname}">
            {/empty}
            <div class="cmt-block">
              <strong>{$Request.session.tpf_login_sign.nickname|default="昵称"}</strong>
              <form role="form" class="cmt-body">
                <div class="form-group">
                  <textarea class="form-control" id="comment" rows="3" placeholder="{empty name="Request.session.tpf_login_sign"}请先登录后再评论{else/}评论内容{/empty}"></textarea>
                </div>
                <div class="pull-left">
                  {empty name="Request.session.tpf_login_sign"}
                  <a href="{:url('ucenter/User/login')}?return_url={:urlencode(url('tcms/posts/detail',['id'=>$list.id],true,true))}" type="submit" class="btn-animate btn-style btn-d btn-primary">提交</a>
                  {else/}
                  <a type="submit" class="btn-animate btn-style btn-d btn-primary submit-comment">提交</a>
                  {/empty}
                </div>
              </form>
            </div>
          </div>
          <script type="text/javascript">
            var layer = layui.layer;
            $(function(){
              $(".reply").click(function(){
                $("#comment").val("@"+$(this).parents(".cmt-block").find(".profile-link").text()+": ").focus();
              });

              $('.rating .voteup,.rating .votedown').each(function(){
                  var pcid=$(this).attr("data-id");
                  if(CookieHandle.getCookie("rating_vate"+pcid)!=null){
                    $(this).addClass("clicked");
                }
              });
            });
          $(".submit-comment").click(function(){
            $.ajax({
              type:"post",
              dataType:"json",
              data:{"posts_id":{$list.id},"comment":$("#comment").val()},
              url:"{:url('tcms/Comment/add')}",
              success:function(data){
                console.log(data);
                if(data.code==0){
                  layer.msg(data.msg,function(){
                    location.reload();
                  });
                }else{
                  layer.msg(data.msg);
                }
              }
            });
          });

          </script>
          <!-- List of comments -->
          <h4 class="text-right">{:Core::loadAction("PostsComments/getCountComments",['where'=>["posts_id"=>$list.id,"pid"=>0,"ischeck"=>1]],"tcms","logic")} 条评论</h4>
          <hr>
          {volist name="listPostsComments" id="vo"}
          <div class="cmt">
            {empty name="vo.headimg"}
            <img src="__THEMES__/img/avatar-default.jpg" alt="用户头像">
            {else/}
            <img src="{$vo.headimg}" alt="{$vo.nickname}">
            {/empty}
            <div class="cmt-block">
              <a href="javascript:;" class="profile-link">{$vo.nickname}</a> <span class="text-muted time">{$vo.datetime|date="Y-m-d H:i",###}</span>
              <span class="rating pull-right">
                <span class="up">{$vo.voteup|default=0}</span>
                <i class="fa fa-thumbs-up voteup" data-id="{$vo.id}"></i>  <i class="fa fa-thumbs-down votedown" data-id="{$vo.id}"></i>
                <span class="down">{$vo.votedown|default=0}</span>
              </span>
              <p class="cmt-body">
                {$vo.comment}
              </p>
              <ul class="list-inline">
                <li><a href="#reply" class="reply">回复</a></li>
              </ul>
            </div>
          </div>
          {/volist}
        </div>
      </div>
      <div class="col-sm-3">
        <form role="form">
            <div class="row">
              <div class="col-sm-12">
                <div class="input-group">
                  <input type="text" class="form-control" placeholder="搜索词">
                  <span class="input-group-btn">            
                    <button class="btn btn-style btn-k btn-primary" type="button"><i class="fa fa-search"></i></button>
                  </span>
                </div>
              </div>
            </div>           
        </form><br><br>
        <div class="panel-heading">
          <strong>分类展示({:Core::loadAction("Posts/countPost",["id"=>1])})</strong>
        </div>    
        <div class="panel">              
          <div class="panel-body">
            <ul>
              {volist name="listChild" id="vo"}
              <li><a href="{:url('tcms/Posts/index',['cid'=>$vo.id])}">{$vo.title} ({$vo.num})</a></li>
              {/volist}
            </ul>
          </div>
        </div>
        <div class="panel-heading">
          <strong>热门话题</strong>
        </div>           
        <div class="panel-group" id="help-nav">

         {volist name=':Core::loadAction("Posts/getPosts",["data"=>["where"=>["channel"=>1,"isdelete"=>0,"ischeck"=>1],"limit"=>5,"order"=>"view desc","field"=>"id,title,abstract"]])' id="vo"}
            <div class="panel">
              <div class="panel-heading blue">
                <a data-toggle="collapse" data-parent="#help-nav" href="#posts-{$vo.id}">
                  {$vo.title}
                </a>
              </div>
              <div id="posts-{$vo.id}" class="panel-collapse collapse {eq name='key' value='0'}in{/eq}">
                <div class="panel-body posts-hot">
                  <p>{$vo.abstract}</p>
                  <a href="{:url('tcms/Posts/detail',['id'=>$vo.id])}">查看详情</a>
                </div>
              </div>
            </div>
            {/volist}
 
        </div>
      </div>
    </div>
  </div>
</div>
{/block}